From: Florian Müllner Date: Tue, 10 Jun 2025 01:15:21 +0000 (+0200) Subject: ci: Use script from tools to run eslint X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~116^2^2~33 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=8101520d86952d6cf1907cc9b822aa68c868d6be;p=gnome-shell.git ci: Use script from tools to run eslint Now that we include a more public version of the script, there is no reason to keep the original script just for CI. Part-of: --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5a935f6bd..683b217f1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -142,8 +142,7 @@ eslint: variables: LINT_LOG: "eslint-report.xml" script: - - export NODE_PATH=$(npm root -g) - - ./.gitlab-ci/run-eslint --output-file ${LINT_LOG} --format junit --stdout + - ./tools/run-eslint.sh --output-file ${LINT_LOG} --format junit --stdout artifacts: reports: junit: ${LINT_LOG} diff --git a/.gitlab-ci/run-eslint b/.gitlab-ci/run-eslint deleted file mode 100755 index c7802ed9d..000000000 --- a/.gitlab-ci/run-eslint +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env node - -const {ESLint} = require('eslint'); - -console.log(`Running ESLint version ${ESLint.version}...`); - -const fs = require('fs'); -const path = require('path'); - -function hasOption(...names) { - return process.argv.some(arg => names.includes(arg)); -} - -function getOption(...names) { - const optIndex = - process.argv.findIndex(arg => names.includes(arg)) + 1; - - if (optIndex === 0) - return undefined; - - return process.argv[optIndex]; -} - -(async function main() { - const outputOption = getOption('--output-file', '-o'); - const outputPath = outputOption ? path.resolve(outputOption) : null; - - const sourceDir = path.dirname(process.argv[1]); - process.chdir(path.resolve(sourceDir, '..')); - - const sources = ['js', 'subprojects/extensions-app/js', 'tests']; - const eslint = new ESLint({cache: true}); - - const results = await eslint.lintFiles(sources); - const formatter = await eslint.loadFormatter(getOption('--format', '-f')); - const resultText = formatter.format(results); - - if (outputPath) { - fs.mkdirSync(path.dirname(outputPath), { recursive: true }); - fs.writeFileSync(outputPath, resultText); - - if (hasOption('--stdout')) { - const consoleFormatter = await eslint.loadFormatter(); - console.log(consoleFormatter.format(results)); - } - } else { - console.log(resultText); - } - - process.exitCode = results.some(r => r.errorCount > 0) ? 1 : 0; -})().catch((error) => { - process.exitCode = 1; - console.error(error); -});